package com.kikikeji.weizhuo.activity.core;

import android.os.Bundle;

import com.kikikeji.weizhuo.util.DebugLog;

public abstract class BaseCoreMVPActivity<T extends BasePresenter<U>, U extends BaseUI> extends BaseCoreFragmentActivity {

    private T mPresenter;

    protected abstract T createPresenter();

    protected abstract U getUi();

    public T getPresenter() {
        return mPresenter;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPresenter = createPresenter();
        mPresenter.onUiReady(getUi(), this);
        mPresenter.onCreate(getIntent().getExtras());
        DebugLog.d("onCreate---");
    }

    @Override
    protected void onStart() {
        super.onStart();
        mPresenter.onStart();
        DebugLog.d("onStart---");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        mPresenter.onUiDestroy(getUi());
        mPresenter.onDestroy();
        DebugLog.d("onDestroy---");
    }

    @Override
    protected void onResume() {
        super.onResume();
        mPresenter.onResume();
        DebugLog.d("onResume---");
    }

    @Override
    protected void onPause() {
        super.onPause();
        mPresenter.onPause();
        DebugLog.d("onPause---");
    }

    @Override
    protected void onStop() {
        super.onStop();
        mPresenter.onStop();
        DebugLog.d("onStop---");
    }

    @Override
    protected int getFragmentContainerId() {
        return 0;
    }

}
